'use strict';

const Controller = require('egg').Controller;

class PermissionController extends Controller {
  async save() {
    const { ctx } = this;
    const bodyRule = {
      name: { type: 'string' },
    };
    ctx.validate(bodyRule); // 校验参数
    const body = ctx.request.body;
    try {
      const result = await ctx.service.permission.save(body);
      ctx.success('成功', result);
    } catch (error) {
      return ctx.failure(error.message);
    }
  }
}

module.exports = PermissionController;
